package sample;

import java.awt.*;
import javax.swing.JFrame;

//练习demo的讲解
public class EXdemo  {
    public static void main(String[] args) {
        //总Frame
        JFrame  frame = new JFrame();
        frame.setSize(400,300);
        frame.setLocation(300,400);
        frame.setBackground(Color.BLACK);
        frame.setVisible(true);
        frame.setLayout(new GridLayout(2,1));

       //四个面板
        Panel p1 = new Panel(new BorderLayout());
        Panel p2=new Panel(new GridLayout(2,1));
        Panel p3 = new Panel(new BorderLayout());
        Panel p4 = new Panel(new GridLayout(2, 2));
        //按钮布局
        p1.add(new Button("East-1"),BorderLayout.EAST);
        p1.add(new Button("West-1"),BorderLayout.WEST);
        p2.add(new Button("P2-BTN-1"));
        p2.add(new Button("P2-BTN-2"));
        p1.add(p2,BorderLayout.CENTER);
        frame.add(p1);
        p3.add(new Button("East-2"),BorderLayout.EAST);
        p3.add(new Button("West-2"),BorderLayout.WEST);
        p4.add(new Button("P4-BTN-1"));
        p4.add(new Button("P4-BTN-2"));
        p3.add(p4,BorderLayout.CENTER);
        frame.add(p3);
        //退出按钮
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}